<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
 function getuser()
 {
	$.post("/user/ajaxbutton", {"op": "getuser","username":$("#username").val()},
		function(data){
			if(data==201)
			{
				$("#usernameerr").html('用户登录帐号已经存在！');
				$("#username").val('');	
			}
		},"json"); 
  }
</script>
<title>添加员工信息</title>
<body class="withvernav">
    <div class="bodywrapper">
        {{include file='/public/leftmenu.tpl'}}
        <div class="centercontent">

            <div class="pageheader">
                <h1 class="pagetitle">添加员工信息</h1>

            </div><!--pageheader-->

            <div id="contentwrapper" class="contentwrapper">

                <div id="basicform" class="subcontent">

                    <!--contenttitle-->

                    <form id="form" class="stdform stdform2" method="post" action="/user/adduser">
                        <p>
                            <label>登录帐号：</label>
                            <span class="field"><input type="text" name="username" id="username" class="_check longinput" value="{{$detail.username}}" onChange="getuser()" /><span id="usernameerr"></span></span>
                        </p>
                        <p>
                            <label>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</label>
                            <span class="field"><input type="text" name="name" id="name" class="_check longinput" value="" /></span>
                        </p>
                        <p>
                            <label>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</label>
                            <span class="field"><input type="password" name="password" id="password" class="_check longinput" value="" /></span>
                        </p>

                        <!-- <p>
                                 <label>Email：</label>
                             <span class="field"><input type="text" name="email" id="email2" class="longinput" name="email" /></span>
                         </p>-->

                        <p>
                            <label>部&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;门：</label>
                            <span class="field">
                                <select class="_check" name="classid" id="selection2">
                                    <option value="">Choose One</option>
                                    {{foreach from=$classid item=li key=key}}
                                    <option value="{{$li.id}}" {{if $detail.classid==$li.id}} selected{{/if}}>{{$li.name}}</option>
                                    {{/foreach}}
                                </select>
                            </span>
                        </p>
                        <p>
                            <label>职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位：</label>
                            <span class="field"><select class="_check" name="department" id="selection2">
                                    <option value="">Choose One</option>
                                    {{foreach from=$usergroup item=li key=key}}
                                    <option value="{{$li.id}}" {{if $detail.department==$li.id}} selected{{/if}}>{{$li.title}}</option>
                                    {{/foreach}}

                                </select>
                            </span>
                        </p>

                        <p>
                            <label>绑定仓库：</label>
                            <span class="field">
                                <select class="_check" name="seawarehouse[]" multiple="multiple" size="15">
                                    {{foreach from=$overseawarehouse item=li key=key}}
                                    <option value="{{$li.name}}"  {{if $detail.seawarehouse}}{{if in_array($li.name,$detail.seawarehouse)}} selected{{/if}}{{/if}}>{{$li.name}}</option>
                                    {{/foreach}}
                                </select>
                            </span>
                        </p>
                        <p>
                            <label>绑定店铺：</label>
                            <span class="field">
                                <select class="_check" name="shopname[]" multiple="multiple" size="15">
                                    {{foreach from=$d_shop item=li key=key}}
                                    <option value="{{$li.name}}" {{if $detail.shopname}}{{if in_array($li.name,$detail.shopname)}} selected{{/if}}{{/if}}>{{$li.name}}</option>
                                    {{/foreach}}
                                </select></span>
                        </p>

                        <p class="stdformbutton">
                            <button id="btn" type="button" class="submit radius2">Submit Button</button>
                            <input type="hidden"  name="uid" value="{{$detail.id}}" />
                        </p>

                    </form>



                    <br />

                </div><!--subcontent-->

                <!--subcontent-->

            </div><!--contentwrapper-->

        </div><!-- centercontent -->


    </div><!--bodywrapper-->

    <script type="text/javascript">

        $('#btn').on('click', function () {

            $('._check').each(function (index, element) {

                if ($(this).val() == '') {

                    s = $(this).parent().siblings('label').html();

                    $(this).after('<br /><span style="color:#ff0000;">请输入' + s.replace(/：/, '') + '</span>');
                    $(this).focus();
                    exit;
                }
            });
            $('#form').submit();
        });

    </script>

</body>
</html>
